package org.apache.rocketmq.example.mysimple;

import org.apache.rocketmq.client.consumer.DefaultLitePullConsumer;
import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.common.message.MessageExt;

import java.util.List;

public class LitePullConsumer {
    public static void main(String[] args) throws MQClientException {
        DefaultLitePullConsumer consumer = new DefaultLitePullConsumer("SimpleConsumer");
        consumer.setNamesrvAddr("127.0.0.1:9876");
        consumer.subscribe("Simple","*");
        consumer.start();
        List<MessageExt> poll = consumer.poll();

        for (MessageExt msg : poll) {
            System.out.println(new String(msg.getBody()));
        }
        consumer.commit();
        consumer.shutdown();

    }
}
